<template>
  <a-card :bordered="false" title="会员等级">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="defaultStatus" slot-scope="text, record">
          <a-icon type="check-circle" v-if="text == 1" />
          <a-icon type="close-circle" v-else />
        </span>
        <span slot="priviledgeFreeFreight" slot-scope="text, record">
           <a-icon type="check-circle" v-if="text == 1" />
          <a-icon type="close-circle" v-else />
        </span>
        <span slot="priviledgeMemberPrice" slot-scope="text, record">
           <a-icon type="check-circle" v-if="text == 1" />
          <a-icon type="close-circle" v-else />
        </span>
        <span slot="priviledgeBirthday" slot-scope="text, record">
           <a-icon type="check-circle" v-if="text == 1" />
          <a-icon type="close-circle" v-else />
        </span>


        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <member-level-modal ref="modalForm" @ok="modalFormOk"></member-level-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '../../utils/mixin'
import { JeecgListMixin } from '../../mixins/JeecgListMixin'
import MemberLevelModal from './levelList/MemberLevelModal.vue'

export default {
  name: 'UmsMemberLevelList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    MemberLevelModal
  },
  data() {
    return {
      description: 'ums_member_level管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '等级名称',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '等级需要的成长值',
          align: 'center',
          dataIndex: 'growthPoint',
          width: 100
        },
        {
          title: '是否为默认等级',
          align: 'center',
          dataIndex: 'defaultStatus',
          scopedSlots: { customRender: 'defaultStatus' }
        },
        {
          title: '免运费标准',
          align: 'center',
          dataIndex: 'freeFreightPoint'
        },
        {
          title: '成长值',
          align: 'center',
          dataIndex: 'commentGrowthPoint'
        },
        {
          title: '特权',
          width: 60,
          children: [
            {
              title: '免邮特权',
              align: 'center',
              dataIndex: 'priviledgeFreeFreight',
              scopedSlots: { customRender: 'priviledgeFreeFreight' }
            },
            {
              title: '价格特权',
              align: 'center',
              dataIndex: 'priviledgeMemberPrice',
              scopedSlots: { customRender: 'priviledgeMemberPrice' }
            },
            {
              title: '生日特权',
              align: 'center',
              dataIndex: 'priviledgeBirthday',
              scopedSlots: { customRender: 'priviledgeBirthday' }
            }]
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'note',
          customRender: function(t) {
            return t ? t : '暂无备注'
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/member/memberLevel/list',
        delete: '/member/memberLevel/delete',
        deleteBatch: '/member/memberLevel/deleteBatch'
      }
    }
  },
  created() {
  },
  computed: {},
  methods: {}
}
</script>
<style scoped>
@import '/src/assets/less/common.less';
</style>